]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/bluetooth: Indicate progress on toggle
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 22 Aug 2022 22:06:42 +0000 (00:06 +0200)
committerMarge Bot <marge-bot@gnome.org>
Sat, 3 Sep 2022 15:05:57 +0000 (15:05 +0000)
Turning bluetooth on or off can be very slow ­– 10-15 seconds on
my system – and we currently don't provide any feedback that
something is indeed happening until the state changes at last.

Address this by using the `acquiring` icon when the adapter is
in a transitioning state.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5773

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2444>

js/ui/status/bluetooth.js

index 9580e7b4c7d87105ffcc55bd3b93d24f658f6e76..d4de597ad7e2591c4e29655c5b297cc8ee972a9b 100644 (file)
@@ -178,14 +178,31 @@ class BluetoothToggle extends QuickToggle {
         this._client.bind_property('active',
             this, 'checked',
             GObject.BindingFlags.SYNC_CREATE);
-        this._client.bind_property_full('active',
+        this._client.bind_property_full('adapter-state',
             this, 'icon-name',
             GObject.BindingFlags.SYNC_CREATE,
-            (bind, source) => [true, source ? 'bluetooth-active-symbolic' : 'bluetooth-disabled-symbolic'],
+            (bind, source) => [true, this._getIconNameFromState(source)],
             null);
 
         this.connect('clicked', () => this._client.toggleActive());
     }
+
+    _getIconNameFromState(state) {
+        switch (state) {
+        case AdapterState.ON:
+            return 'bluetooth-active-symbolic';
+        case AdapterState.OFF:
+        case AdapterState.ABSENT:
+            return 'bluetooth-disabled-symbolic';
+        case AdapterState.TURNING_ON:
+        case AdapterState.TURNING_OFF:
+            return 'bluetooth-acquiring-symbolic';
+        default:
+            console.warn(`Unexpected state ${
+                GObject.enum_to_string(AdapterState, state)}`);
+            return '';
+        }
+    }
 });
 
 var Indicator = GObject.registerClass(